<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">全局设备统计-登记渠道 </ui:define>
    <ui:define name="content">
        <h:form>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>

                        <p:columnToggler datasource="statCheckInDataTable" trigger="toggler"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         update="@form"/>
                        <p:commandButton value="重置" icon="fa fa-refresh" actionListener="#{statCheckInBean.onRest()}"
                                         update="@form"/>
                        <p:commandButton value="导出" icon="fa fa-download"
                                         ajax="false">
                            <p:dataExporter type="csv" target="statCheckInDataTable" fileName="export" encoding="GBK"/>
                        </p:commandButton>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="8" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-2"
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;">

                                <p:outputLabel for="startDate" value="开始日期"/>
                                <p:calendar id="startDate" value="#{statCheckInBean.$.startDate}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"/>

                                <p:outputLabel for="endDate" value="结束日期"/>
                                <p:calendar id="endDate" value="#{statCheckInBean.$.endDate}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"/>

                                <p:outputLabel for="acId" value="活动id"/>
                                <p:inputText id="acId" placeholder="请输入" value="#{statCheckInBean.$.activityId}"/>

                                <p:outputLabel for="platform" value="平台"/>
                                <p:selectOneMenu id="platform" value="#{statCheckInBean.$.platform}">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItem itemLabel="ios" itemValue="ios"/>
                                    <f:selectItem itemLabel="android" itemValue="android"/>
                                </p:selectOneMenu>

                                <p:outputLabel for="productId" value="产品"/>
                                <p:selectOneMenu id="productId" value="#{statCheckInBean.$.productId}"
                                                 filter="true" filterMatchMode="contains">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItems
                                            value="#{statCheckInBean.commProductIds}"
                                            var="product"
                                            itemLabel="#{product.name}" itemValue="#{product.productId}"/>
                                </p:selectOneMenu>

                                <p:outputLabel for="channelCode" value="渠道"/>
                                <p:selectOneMenu id="channelCode" value="#{statCheckInBean.$.channelCode}"
                                                 filter="true" filterMatchMode="contains">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItems
                                            value="#{statCheckInBean.commProductChannels}"
                                            var="channel"
                                            itemLabel="#{channel.channelName}" itemValue="#{channel.channelCode}"/>
                                </p:selectOneMenu>

                                <p:outputLabel for="channelGroup" value="渠道分类"/>
                                <p:selectOneMenu id="channelGroup" value="#{statCheckInBean.$.channelGroup}"
                                                 filter="true" filterMatchMode="contains">
                                    <p:ajax event="change" listener="#{statCheckInBean.onChangeChannelGroup()}"
                                            update="secondaryChannelGroup"/>
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItems value="#{statCheckInBean.dictionaries[DictionaryCode.CHANNEL_GROUP]}"
                                                   var="dic"
                                                   itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                </p:selectOneMenu>

                                <p:outputLabel for="secondaryChannelGroup" value="二级渠道分类"/>
                                <p:selectOneMenu id="secondaryChannelGroup" value="#{statCheckInBean.$.secondaryChannelGroup}"
                                                 filter="true" filterMatchMode="contains">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItems value="#{statCheckInBean.secondaryChannelGroups}"
                                                   var="dic"
                                                   itemLabel="#{dic.channelName}" itemValue="#{dic.id}"/>
                                </p:selectOneMenu>

                            </p:panelGrid>
                        </div>
                        <div class="card">
                            <p:dataTable id="statCheckInDataTable"
                                         style="width: 100%"
                                         var="record"
                                         value="#{statCheckInBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         scrollWidth="97%"
                                         reflow="true"
                                         selection="#{statCheckInBean.selectedRecords}"
                                         resizableColumns="true">

                                <p:column headerText="日期">
                                    <h:outputText value="#{record.createDate}">
                                        <f:convertDateTime pattern="#{constants:get('DATE_FORMAT')}"/>
                                    </h:outputText>
                                </p:column>
                                <p:column headerText="平台">
                                    <h:outputText value="#{record.platform}"/>
                                </p:column>
                                <p:column headerText="父级产品">
                                    <h:outputText value="#{statCheckInBean.translate(DictionaryCode.LARGE_COMMON_PRODUCT,record.parentProductId)}"/>
                                </p:column>
                                <p:column headerText="产品">
                                    <h:outputText value="#{statCheckInBean.translateProduct(record.productId)}"/>
                                </p:column>
                                <p:column headerText="渠道">
                                    <h:outputText value="#{statCheckInBean.translateProductChannel(record.channelCode)}"/>
                                </p:column>
                                <p:column headerText="活动ID">
                                    <h:outputText value="#{record.activityId}"/>
                                </p:column>
                                <p:column headerText="渠道分类">
                                    <h:outputText
                                            value="#{statCheckInBean.translate(DictionaryCode.CHANNEL_GROUP,record.channelGroup)}"/>
                                </p:column>
                                <p:column headerText="二级渠道分类">
                                    <h:outputText
                                            value="#{statCheckInBean.translateSecondaryChannelGroup(record.secondaryChannelGroup)}"/>
                                </p:column>
                                <p:column headerText="H5-访问人数">
                                    <h:outputText value="#{record.h5ViewPageCount}"/>
                                </p:column>
                                <p:column headerText="H5-登记人数">
                                    <h:outputText value="#{record.h5CheckInCount}"/>
                                </p:column>
                                <p:column headerText="H5-注册人数a(全局)">
                                    <h:outputText value="#{record.h5RegisterCountA}"/>
                                </p:column>
                                <p:column headerText="H5-注册人数b(大产品)">
                                    <h:outputText value="#{record.h5RegisterCountB}"/>
                                </p:column>
                                <p:column headerText="登录人数">
                                    <h:outputText value="#{record.loginCount}"/>
                                </p:column>
                                <p:column headerText="注册人数a（全库）">
                                    <h:outputText value="#{record.appRegisterCountA}"/>
                                </p:column>
                                <p:column headerText="注册人数b（大产品）">
                                    <h:outputText value="#{record.appRegisterCountB}"/>
                                </p:column>
                                <p:column headerText="参与uv和（手机号）">
                                    <h:outputText value="#{record.uvPhone}"/>
                                </p:column>
                                <p:column headerText="参与uv和（api甲方）">
                                    <h:outputText value="#{record.uvApi}"/>
                                </p:column>
                                <p:column headerText="api进件人数（手机号）">
                                    <h:outputText value="#{record.apiApplyCount}"/>
                                </p:column>
                                <p:column headerText="api放款人数（手机号）">
                                    <h:outputText value="#{record.apiLendCount}"/>
                                </p:column>
                                <p:column headerText="api放款额（手机号）">
                                    <h:outputText value="#{record.apiLendAmount}"/>
                                </p:column>
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
